package com.example.yy.fragementtest318yy.Fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.example.yy.fragementtest318yy.R;

/**
 * Created by Neusoft on 2017/4/9.
 */

public class Fragment6 extends Fragment {
    private TextView tvinfo;
    private TextView tvname;
    private Button btnlogout;
    private View view=null;
    private Context context;
    private String username="",tele="";
    private SharedPreferences sp;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        context=getActivity();
        //动态加载Fragment2的布局文件
        view=inflater.inflate(R.layout.fragment6,container,false);
        //获取布局上的控件，注意通过view获取
        tvinfo=(TextView)view.findViewById(R.id.textView13);
        btnlogout=(Button)view.findViewById(R.id.button4);
        btnlogout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getActivity().onBackPressed();
            }
        });
        tvname=(TextView)view.findViewById(R.id.textView14);
        sp=context.getSharedPreferences("login",Context.MODE_PRIVATE);
        readSP();
        tvname.setText(username);
        return view;
    }

    private void readSP() {
        username=sp.getString("username",null);
    }


}
